'''
Company: TWL
Author: xue jian
Email: xuejian@kanzhun.com
Date: 2020-11-03 09:18:15
'''
#
# @lc app=leetcode.cn id=941 lang=python3
#
# [941] 有效的山脉数组
#

# @lc code=start
class Solution:
    def validMountainArray(self, A: List[int]) -> bool:
        if len(A)<3:
            return False
        flag = 0
        cnt = 0
        for i in range(1, len(A)):
            if not flag:
                if A[i-1]<A[i]:
                    cnt+=1
                elif A[i-1]>A[i] and cnt:
                    flag=1
                    cnt=1
                else:
                    return False
            else:
                if A[i-1]>A[i]:
                    cnt+=1
                else:
                    return False
        return cnt>0 and flag>0

        
# @lc code=end

